<template>
  <div id="app">
    <template>
      <div>
        <div>
          <label for="orderNo">订单号：</label>
          <input id="orderNo" v-model="inputOrderId" />
          <button @click="query" v-permission="orderInfo.role">查询</button>
        </div>
        <div class="logistics-info" v-if="isShow">
          <GoodInfo :goodInfo="orderInfo.goodInfo" 
          >
            <template #desc>
              <img
                v-if="orderInfo.goodInfo.type == 1"
                src="https://cn.bing.com/images/search?view=detailV2&ccid=FHUeA%2Bb8&id=2AA36FD908437498EA965AC27CB4BB106E900D70&thid=OIP.FHUeA-b8xyKDZWu6EuTbVQHaFF&mediaurl=https%3A%2F%2Fts1.cn.mm.bing.net%2Fth%2Fid%2FR-C.14751e03e6fcc72283656bba12e4db55%3Frik%3DcA2QbhC7tHzCWg%26riu%3Dhttp%253a%252f%252fwww.news.cn%252fent%252f20230116%252fc04bf1f0b9994ffa802c6a52930cd440%252f20230116c04bf1f0b9994ffa802c6a52930cd440_202301167eb928901db94d1ab200ea57a0e5545b.jpg%26ehk%3DZGKlmoM09EDLFTUxbMWU7DrA0Zy8otXiZ8jWDFV0Qyw%253d%26risl%3D%26pid%3DImgRaw%26r%3D0&exph=686&expw=1000&q=%E4%B8%89%E4%BD%93&simid=607997658704979206&form=IRPRST&ck=63AA2CF417523267FC9E9AFB66ACE4ED&selectedindex=4&itb=0&cw=1316&ch=752&ajaxhist=0&ajaxserp=0&vt=0&sim=11"
                alt=""
              />
              <span v-else>这是一本好书</span>
            </template>
          </GoodInfo>
          <LogisticInfo :orderInfo="orderInfo"></LogisticInfo>
        </div>
      </div>
    </template>
  </div>
</template>

<script>
import GoodInfo from "./components/GoodInfo.vue";
import LogisticInfo from "./components/LogisticInfo.vue";
export default {
  name: "App",
  components: { GoodInfo, LogisticInfo },
  directives:{
    permission:{
     inserted(el,binding) {
    const roles = ['admin', 'zhangsan', 'lisi']// 允许的角色列表
    if (!roles.includes(binding.value)) {
      el.disabled = true
    }
     }
  }},
  methods: {
    query() {

        setTimeout(
          function(){
          this.orderInfo={
        // orderNo: this.currentOrderNo,
        role: "admin", // 角色 ==> 用于判断是否有查看用户详情的权限
        logisticsStatus: 2, // 0 未发货 1 已发货 2 已签收 3 未签收
        logisticsCompany: "顺丰速运", // 快递公司的名称
        logisticsNo: "SF123456789", // 快件运单号
        logisticsInfo: [
          {
            time: "2023-02-01 10:00:00", // 时间
            content: "快件已发货", // 快递状态
          },
          {
            time: "2023-02-02 09:00:00",
            content: "快件到达深圳中心",
          },
          {
            time: "2023-02-03 08:00:00",
            content: "快件派送中",
          },
          {
            time: "2023-02-04 16:00:00",
            content: "已签收",
          },
        ],
        goodInfo: {
          // 商品信息
          goodNo: "12345678912312", // 商品id
          goodName: "三体", // 商品名称
          type: 1, // 0 代表的是文本 1代表的是 图片
          // desc 描述 ==> 可以是图片 也可以是其他的东西。数据可以随便改
          desc: "	http://registakeaway.itheima.net/common/download?name=9b978122-179a-4b0e-891b-595d0cd3d875.jpg",
        },
      }
      
        },1000)
        this.isShow=true
      // xxxx.includes(this.inputOrderId)
    },
  },
  data() {
    return {
      isShow:false,
      inputOrderId: "",
      statusText: "",
      orderInfo:
      {
        // orderNo: this.currentOrderNo,
        role: "admin", // 角色 ==> 用于判断是否有查看用户详情的权限
        logisticsStatus: 2, // 0 未发货 1 已发货 2 已签收 3 未签收
        logisticsCompany: "顺丰速运", // 快递公司的名称
        logisticsNo: "SF123456789", // 快件运单号
        logisticsInfo: [
          {
            time: "2023-02-01 10:00:00", // 时间
            content: "快件已发货", // 快递状态
          },
          {
            time: "2023-02-02 09:00:00",
            content: "快件到达深圳中心",
          },
          {
            time: "2023-02-03 08:00:00",
            content: "快件派送中",
          },
          {
            time: "2023-02-04 16:00:00",
            content: "已签收",
          },
        ],
        goodInfo: {
          // 商品信息
          goodNo: "12345678912312", // 商品id
          goodName: "三体", // 商品名称
          type: 1, // 0 代表的是文本 1代表的是 图片
          // desc 描述 ==> 可以是图片 也可以是其他的东西。数据可以随便改
          desc: "	http://registakeaway.itheima.net/common/download?name=9b978122-179a-4b0e-891b-595d0cd3d875.jpg",
        },
      }
    };
  },
};
</script>

<style>
.logistics-info {
  border: 1px solid #ccc;
  border-radius: 5px;
  box-shadow: 0px 0px 10px #eee;
  padding: 10px;
  font-size: 14px;
}

.logistics-info-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.logistics-info-header-left {
  display: flex;
  align-items: center;
}

.logistics-status {
  font-weight: bold;
  font-size: 16px;
  color: #007bff;
}

.logistics-company,
.logistics-no {
  margin-left: 10px;
  font-size: 14px;
  color: #333;
}

.logistics-info-list {
  list-style: none;
  padding: 0;
  margin: 0;
  max-height: 230px;
  overflow-y: auto;
}

.logistics-info-list li {
  display: flex;
  margin-bottom: 10px;
}

.logistics-info-list-time {
  font-size: 12px;
  color: #999;
  width: 80px;
  text-align: right;
  margin-right: 10px;
}

.logistics-info-list-content {
  font-size: 14px;
  color: #333;
}
img {
  width: 50px;
  height: 50px;
}
.redClass{
  color: red;
}
.orangeClass{
  color: orange;
}
.yellowClass{
  color: yellow;
}
.greenClass{
  color: green;
}
.blueClass{
  color: blue;
}
</style>
